GBML manual / Drawing

angle

Rotation in degrees (0 = east, counterclockwise). Any value works - it wraps automatically.

Works differently on Game Boy - A turned, resized or leaned sprite shows the nearest look the build draws ahead of time: turns in steps (Project Settings: Sprite turn steps), a few sizes and leans, and a negative size mirrors exactly. The looks share the 384 tiles of video memory, so there is room for few.

Works differently on Game Boy Color - On the Game Boy Color a turned, resized or leaned sprite shows the nearest of the looks the build drew ahead of time: turns in steps (Project Settings: Sprite turn steps), a few sizes and leans. A negative size mirrors it exactly.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

angle: real

Description

Rotation in degrees, 0 being straight east and increasing values turning counter-clockwise on screen - the same convention every angle in this manual uses (see Where the machine shows through for why, confirmed against the hardware's own affine math rather than assumed). Any value works; it wraps on its own, so there is never a need to clamp it back into 0..360 by hand. See Budgets for what a non-zero angle costs on this hardware: one of the 32 matrices, given back the moment angle is exactly 0 again (and the scales exactly 1, and the lean exactly 0). An angle that creeps toward 0 and never reaches it - a spring, or a turn multiplied down every frame - keeps the matrix, so end it on an exact 0 (see xshear for the test).

Example

angle += 3;

Spins steadily, 3 degrees a frame - a full turn every two seconds at 60 frames a second.

A real capture - the arrow two frames into its turn, only 6 degrees round, so it still points almost due eastA real capture - the arrow two frames into its turn, only 6 degrees round, so it still points almost due east
A real capture - the arrow two frames into its turn, only 6 degrees round, so it still points almost due east
A real capture - the same arrow after 30 frames of angle += 3, now pointing northA real capture - the same arrow after 30 frames of angle += 3, now pointing north
A real capture - the same arrow after 30 frames of angle += 3, now pointing north

On the GBA

A turned or scaled sprite uses one of the hardware’s 32 turning slots while it is turned or scaled, and gives the slot back the moment it is exactly plain again - angle exactly 0 and xscale/yscale exactly 1. Watch out for a value that creeps towards 0 and never quite arrives: a spring that settles at 0.0105 is still turned, so it keeps its slot for as long as the object lives, even once it is far too small to see. End a spring on exactly 0. A turned or enlarged picture is drawn into a box at most TWICE the size of its sprite (Gbabel asks the hardware for it whenever the picture could stick out) - past that the hardware cuts it off, so draw it from a bigger sprite.